<template>
  <div class="recomend">
    <div class="title">热销推荐</div>
    <ul>
      <li :key="item.id" class="item border-bottom" v-for="item of recommendList">
        <img :src="item.imgUrl" class="item-img">
        <div class="item-info">
          <p class="item-title">{{item.title}}</p>
          <p class="item-desc">{{item.desc}}</p>
          <button class="item-button">查看详情</button>
        </div>
      </li>
    </ul>
  </div>
</template>

<script type="text/javascript">
  export default {
    name: 'HomeRecommend',
    props: {
      recommendList: Array
    },
    data () {
      return {}
    },
    computed: {}
  }
</script>
<!-- 后面的scoped是必须的，表示它只对当前组件有效，不会影响到其他组件的样式 -->
<style lang="stylus" scoped>
  @import "../../../assets/styles/variables.styl"

  .title
    margin-top: .2rem
    line-height: .8rem
    background: #eee
    text-indent: .2rem

  .item
    display: flex
    height: 1.9rem
    overflow: hidden

    .item-img
      width: 1.7rem
      height: 1.7rem
      padding: .1rem

    .item-info
      flex: 1
      padding: .1rem
      /* 重点，如果没有这个min-width，ellipsis就不会出现“...”，如果容器的宽度小于 flex item 本身的宽度，flex item 会拒绝收缩，除非你给 flex item 的min-width、max-width或width指定一个值 */
      min-width: 0

      .item-title
        line-height: .54rem
        font-size: .32rem
        ellipsis()

      .item-desc
        line-height: .4rem
        color: #ccc
        ellipsis()

      .item-button
        line-height: .44rem
        background: #ff9300
        padding: 0 .1rem
        border-radius: .06rem
        color: #fff

</style>
